<template>
	<view class="container">
		<view class="navlist u-flex u-col-center u-row-between">
			<view class="item" :class="{on:navindex==item.type}" v-for="(item,index) in navlist" :key="index"
				@click="change(item)">
				{{item.name}}
			</view>
		</view>
		<view class="list">
			<view class="item" v-for="(item,index) in list" :key="index" @click="goinfo(item)">
				<view class="u-flex u-row-between">
					<view class="title">
						交易号：{{item.orderNumber}}
						<span @click="$copyFun(item.orderNumber)">复制</span>
					</view>
					<view class="">
						<view class="t" v-if="item.orderIng == 1">
							<view class="t t1" v-if="item.cancelStatus == 1">
								交易关闭
							</view>
							<view class="t t3" v-else>
								进行中
							</view>
						</view>
						<view class="" v-else>
							<view class="t t2" v-if="item.orderStatus == 9">
								交易关闭
							</view>
							<view class="t t1" v-if="item.orderStatus == 6">
								交易完成
							</view>
						</view>
					</view>
				</view>
				<view class="tit_cent1  ">
					<view class="u-flex tit_left">
						<image v-if="item.quotationImage" @click="$previewImage([item.quotationImage])" :src="item.quotationImage"
							mode="aspectFill"></image>
							<image :src="webconfigImg" mode="aspectFill" v-else></image>
					</view>
					<view class="tit_right">
						<view class="u-row-between" style="display: flex;">
							<view class="name">
								{{item.quotationName}}
							</view>
							<view class="reds" v-if="item.breachType==0||item.breachType==1">
								{{item.iswho?'我方违约':'对方违约'}}
							</view>
						</view>
						<view class="price_block">
							<view class="">押金 ￥{{item.quotationPrice}}
								<span v-if="item.orderIng == 1" style="color: #979797;">
									交易完成后退回
								</span>
								<span v-else>
									<span v-if="item.breachType==0||item.breachType==1">
										{{item.iswho?'违约押金扣除':'已原路退回'}}
									</span>
								</span>
							</view>
							<view class="">交易系统费 ￥{{item.amountService}}
								<!-- <span v-if="item.breachType">已原路退回</span> -->
							</view>
						</view>
					</view>
				</view>
				<view class="ttts">
					<span v-if="item.breachType==0||item.breachType==1">
						{{item.iswho?'':'维权理赔成功'}}
					</span>
				</view>
			</view>
			<view class="nolist" v-if="nolist">
				<image src="/static/kong2.png" mode="aspectFill"></image>
				<text>暂无信息</text>
			</view>
		</view>

	</view>
</template>

<script>
	import {
		createOrderlist
	} from '@/common/http.api.js';
	export default {
		data() {
			return {
				webconfigImg: uni.getStorageSync('webconfig').productDefaultImage,
				navlist: [{
						name: '全部',
						type: 0
					},
					{
						name: '进行中',
						type: 1
					},
					{
						name: '交易关闭',
						type: 2
					},
					{
						name: '交易完成',
						type: 3
					}
				],
				navindex: 0,
				list: [],
				params: {
					page: 1,
					limit: 10,
					tab: 0
				},
				nolist: false,

			}
		},
		onLoad() {
			this.getlist()
		},
		onReachBottom() {
			this.params.page++
			this.getlist()
		},
		methods: {
			goinfo(item) {
				uni.navigateTo({
					url: `/pages/index/newpage/tradinfo?id=${item.id}`
				})

			},
			getlist() {
				this.params.tab = this.navindex
				createOrderlist(this.params).then(res => {
					if (res.code == 200) {
						res.data.list.forEach(item => {
							let id = uni.getStorageSync('userInfo').id
							// breachType == 0 发布方
							if (id == item.userId && item.breachType == 1) {
								// 我方
								item.iswho = true
							} else if (id == item.quotationUserId && item.breachType == 0) {
								// 我方
								item.iswho = true
							} else {
								// 	// 对方
								item.iswho = false
							}
						})
						console.log(this.list);
						this.list.push(...res.data.list)
						let total = Math.ceil(res.data.total / this.params.limit);
						this.nolist = total == 0
					}
				})
			},
			change(item) {
				if (this.navindex != item.type) {
					this.navindex = item.type
					this.list = []
					this.params.page = 1
					this.getlist()
				}
			},
		}
	}
</script>

<style lang="scss">
	$color: #FF6F07;

	page {
		background: #F9F9F9;
	}

	::-webkit-scrollbar {
		width: 0;
		height: 0;
		color: transparent;
		display: none;
	}

	.container {
		.navlist {
			position: sticky;
			top: 0;
			height: 80rpx;
			line-height: 80rpx;
			width: 100%;
			background-color: #fff;
			z-index: 999;
			border-bottom: 2rpx solid #eee;
			overflow-x: auto;
			white-space: nowrap;
			-webkit-overflow-scrolling: touch;

			/* 优化移动端滚动体验（平滑滚动） */
			.item {
				min-width: 120rpx;
				display: inline-block;
				margin-right: 20rpx;
				text-align: center;
				font-size: 28rpx;
				color: #8E8E8E;
			}

			.on {
				color: $color;
				font-weight: 600;
				position: relative;

				&::after {
					content: '';
					position: absolute;
					bottom: 0;
					left: 50%;
					width: 48rpx;
					height: 4rpx;
					background: $color;
					border-radius: 2rpx;
					margin-left: -24rpx;
				}
			}
		}

		.nolist {
			padding: 100rpx 30rpx;
			display: flex;
			flex-direction: column;
			align-items: center;
			justify-content: center;
			text-align: center;

			image {
				width: 160rpx;
				height: 136rpx;
			}

			text {
				font-size: 24rpx;
				color: #999;
				margin-top: 20rpx;
			}
		}

		.list {
			// padding: 0rpx 30rpx;
			box-sizing: border-box;

			.item {
				padding: 22rpx 20rpx;
				width: 710rpx;
				background: #FFFFFF;
				border-radius: 12rpx 12rpx 12rpx 12rpx;
				box-sizing: border-box;
				margin: 20rpx auto;
				.ttts{
					font-family: PingFang SC, PingFang SC;
					font-weight: 500;
					font-size: 24rpx;
					color: #FF6F07;
					text-align: right;
					margin-top: 15rpx;
				}
				.title {
					font-family: PingFang SC, PingFang SC;
					font-weight: 500;
					font-size: 24rpx;
					color: #979797;

					span {
						font-family: PingFang SC, PingFang SC;
						font-weight: 500;
						font-size: 24rpx;
						color: #FF6F07;
						margin-left: 20rpx;
					}
				}

				.t {
					font-family: PingFang SC, PingFang SC;
					font-weight: 500;
					font-size: 28rpx;
					color: #FF6F07;
				}

				.t1 {
					color: #11192D;
				}

				.t2 {
					color: #979797;
				}
				.t3{
					color: #54BD6A;
				}

				.tit_cent1 {
					margin-top: 24rpx;
					display: flex;

					.tit_left {
						image {
							width: 160rpx;
							height: 160rpx;
							border-radius: 12rpx 12rpx 12rpx 12rpx;
						}
					}

					.tit_right {
						margin-left: 20rpx;
						flex: 1;
						display: flex;
						flex-direction: column;
						justify-content: space-between;

						.name {
							width: 360rpx;
							font-family: PingFang SC, PingFang SC;
							font-weight: 500;
							font-size: 28rpx;
							color: #11192D;
							overflow: hidden;
							text-overflow: ellipsis;
							display: -webkit-box;
							-webkit-line-clamp: 2; //几行就填几
							-webkit-box-orient: vertical;
						}

						.reds {
							font-family: PingFang SC, PingFang SC;
							font-weight: 500;
							font-size: 24rpx;
							color: #FE1515;
						}

						.price_block {
							height: 72rpx;
							background: #F9F9F9;
							border-radius: 8rpx 8rpx 8rpx 8rpx;
							font-family: PingFang SC, PingFang SC;
							font-weight: 500;
							font-size: 20rpx;
							color: #979797;
							padding: 6rpx 12rpx;
							box-sizing: border-box;

							span {
								font-family: PingFang SC, PingFang SC;
								font-weight: 500;
								font-size: 20rpx;
								color: #FF6F07;
								margin-left: 10rpx;
							}
						}
					}
				}


			}

		}



	}
</style>